//
//  CustomAltView.m
//  Gamebox7724
//
//  Created by Mac on 2017/2/13.
//  Copyright © 2017年 pipaw. All rights reserved.
//

#import "CustomAltView.h"
#define baseTag 800
@implementation CustomAltView

/*
 *  显示弹框 type=0为领号 type=1为淘号
 */
//+ (instancetype)showGetNumCustomAltViewWithType:(NSString *)type andNum:(NSString *)num
//{
//    
//    
//    UIWindow *window = [[UIApplication sharedApplication] keyWindow];
//    CustomAltView *altView = [[CustomAltView alloc] initWithFrame:CGRectMake(0, 0, UISCREENWIDTH, UISCREENHEIGHT)];
//    altView.backgroundColor = UIRGB(0, 0, 0, 0.5);
//    [window addSubview:altView];
//    
//    float viewWhiteSpaceH = 35;
//    float viewWhiteWidth = UISCREENWIDTH - 2 * viewWhiteSpaceH;
//    float viewWhiteHeight = 150.f;
//    float viewWhiteSpaceV = (UISCREENHEIGHT - viewWhiteHeight) / 2.f;
//    
//    UIView *viewWhite = [[UIView alloc] initWithFrame:CGRectMake(viewWhiteSpaceH, viewWhiteSpaceV, viewWhiteWidth, viewWhiteHeight)];
//    viewWhite.backgroundColor = [UIColor whiteColor];
//    viewWhite.layer.cornerRadius = 5;
//    viewWhite.layer.masksToBounds = YES;
//    [altView addSubview:viewWhite];
//    
//    UILabel *labelTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 15, CGRectGetWidth(viewWhite.frame), 20)];
//    labelTitle.textColor = TEXT_COLOR;
//    labelTitle.font = [UIFont systemFontOfSize:20];
//    labelTitle.textAlignment = NSTextAlignmentCenter;
//    if ([type integerValue] == 0) {
//        labelTitle.text = @"领取成功";
//    }else {
//        labelTitle.text = @"淘号成功";
//    }
//    [viewWhite addSubview:labelTitle];
//    
//    UILabel *labelNum = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(labelTitle.frame) + 15, CGRectGetWidth(viewWhite.frame), 20)];
//    labelNum.textColor = UIRGB(66, 157, 62, 1);
//    labelNum.font = [UIFont systemFontOfSize:15];
//    labelNum.textAlignment = NSTextAlignmentCenter;
//    labelNum.text = [NSString stringWithFormat:@"激活码:%@", num];
//    [viewWhite addSubview:labelNum];
//    
//    UILabel *labelTip = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(labelNum.frame), CGRectGetWidth(viewWhite.frame), 20)];
//    labelTip.textColor = TEXT_SUB_COLOR;
//    labelTip.font = [UIFont systemFontOfSize:13];
//    labelTip.textAlignment = NSTextAlignmentCenter;
//    if ([type integerValue] == 0) {
//        labelTip.text = @"请尽快使用，以免进入淘号被淘走";
//    }else {
//        labelTip.text = @"淘到的号不一定能兑换，请尽快使用";
//    }
//    [viewWhite addSubview:labelTip];
//    
//    NSArray *arr = @[@"关闭", @"复制"];
//    for (int i = 0; i < 2; i++) {
//        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
//        btn.frame = CGRectMake(i * viewWhiteWidth / 2.f, viewWhiteHeight - 40, viewWhiteWidth / 2.f, 40);
//        [btn setTitle:arr[i] forState:UIControlStateNormal];
//        [viewWhite addSubview:btn];
//        btn.tag = baseTag + i;
//        [btn addTarget:altView action:@selector(clickCloseAction:) forControlEvents:UIControlEventTouchUpInside];
//        
//        if (i == 0) {
//            [btn setTitleColor:TEXT_COLOR forState:UIControlStateNormal];
//        }else {
//            btn.backgroundColor = UIRGB(66, 157, 62, 1);
//        }
//    }
//    
//    
//    return altView;
//}

/**
 * 关闭 复制
 */
- (void)clickCloseAction:(UIButton *)btn
{
    // 移除视图
    [self removeFromSuperview];
    
    // 回调：btn.tag - baseTag=0为关闭   btn.tag - baseTag=1为复制
    if (self.clickCloseCallBack) {
        self.clickCloseCallBack(btn.tag - baseTag);
    }
}

/**
 *  系统默认弹窗
 */
+ (void)createAltViewWithTitle:(NSString *)title andMessage:(NSString *)message
{
    UIAlertView *alt = [[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:@"好的" otherButtonTitles:nil, nil];
    [alt show];
}


@end
